package test2;

import java.util.Arrays;
import java.util.HashMap;
//字符与字符串
public class Test2 {

    public static void main(String[] args) {
        String str="hello";
        char[] chars=str.toCharArray();//把str指向的字符串对象，变为字符数组
        System.out.println(Arrays.toString(chars));
    }


    public static void main3(String[] args) {
        String str="hello";
        char ch=str.charAt(2);//获取到2下标的字符
        System.out.println(ch);
    }




    public static void main2(String[] args) {
        //把数组的一部分变为字符串
        char[] val={'a','b','c','d','e','f'};
        String ret=new String(val,1,3);
        System.out.println(ret);
    }

    public static void main1(String[] args) {
       //把数组整体转换为字符串
        char[] val={'a','b','c'};
        String ret=new String(val);
        System.out.println(ret);
    }



}
